<?php

namespace App\Http\Requests\Api;

class ProductRequest extends FormRequest
{
    public function rules()
    {
        switch($this->method())
        {
            case 'POST':
                return [
                    'name' => 'required|string',
                    'thumbnail' => 'required|string',
                    'company_id' => 'required|exists:companies,id',
                    'description' => 'string',
                    'review_count' => 'integer',

                ];
                break;

            case 'PATCH':
                return [
                    'name' => 'string',
                    'thumbnail' => 'string',
                    'company_id' => 'exists:companies,id',
                    'description' => 'string',
                    'review_count' => 'integer',

                ];
                break;
        }
    }

    public function attributes()
    {
        return [
            'name' => '产品名称',
            'thumbnail' => '产品缩略图',
            'company_id' => '产品商家id',
            'review_count' => '评价数量',

        ];
    }
}
